package cn.cxion.chat.app.util;

import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;

import com.lqr.optionitemview.OptionItemView;

public class UiHelp {

    public static UiHelp instance = null;


    public static void init() {
        if (instance == null) {
            synchronized (UiHelp.class) {
                instance = new UiHelp();
            }
        }
    }

    public static UiHelp getInstance() {
        return instance;
    }

    public UiHelp setText(String str, TextView textView) {
        if (!StringUtil.isEmpty(str)) {
            textView.setText(str);
        }
        return this;
    }

    public UiHelp setText(String str, EditText textView) {
        if (!StringUtil.isEmpty(str)) {
            textView.setText(str);
        }
        return this;
    }

    public UiHelp setText(String str, OptionItemView textView) {
        if (!StringUtil.isEmpty(str)) {
            textView.setTitleText(str);
        }
        return this;
    }

    public static void hideKeyboard(View view){
        InputMethodManager methodManager= (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        if(methodManager!=null){
            methodManager.hideSoftInputFromWindow(view.getWindowToken(),0);
        }

    }
}
